package com.chenyue.cm.api.member;

import com.chenyue.cm.auth.Login;
import com.chenyue.cm.auth.LoginUser;
import com.chenyue.cm.bean.Success;
import com.chenyue.cm.member.service.JdMemberService;
import com.chenyue.cm.member.vo.MemberVo;
import com.chenyue.cm.user.domain.JdAppUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author libingxing
 */
@Api(tags = "我的月卡")
@RestController
@RequestMapping("/api/member")
public class ApiMemberController {

    private final JdMemberService memberService;

    public ApiMemberController(JdMemberService memberService) {
        this.memberService = memberService;
    }

    @Login
    @GetMapping("/getMember")
    @ApiOperation("月卡详情")
    public Success<MemberVo> getMember(
           @ApiIgnore @LoginUser JdAppUser user
    ) {
        MemberVo member = memberService.getMember(Integer.valueOf(user.getId()));
        return Success.success(member);
    }
}
